package io.renren.modules.user.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.renren.modules.combat.entity.TFightDictionaryEntity;
import io.renren.modules.generator.entity.TTrainingDictionaryEntity;
import io.renren.modules.user.entity.TPeopleDictionaryEntity;
import io.renren.modules.user.service.TPeopleDictionaryService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 人员数据字典
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2019-08-02 10:30:00
 */
@RestController
@RequestMapping("/tpeopledictionary")
public class   TPeopleDictionaryController {
    @Autowired
    private TPeopleDictionaryService tPeopleDictionaryService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("user:tpeopledictionary:list")
    public R list(@RequestBody Map<String, Object> params){
        PageUtils page = tPeopleDictionaryService.queryPage(params);
        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    //@RequiresPermissions("user:tpeopledictionary:info")
    public R info(@PathVariable("id") Integer id){
		TPeopleDictionaryEntity tPeopleDictionary = tPeopleDictionaryService.getById(id);

        return R.ok().put("tPeopleDictionary", tPeopleDictionary);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("user:tpeopledictionary:save")
    public R save(@RequestBody TPeopleDictionaryEntity tPeopleDictionary){
		tPeopleDictionaryService.save(tPeopleDictionary);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
   // @RequiresPermissions("user:tpeopledictionary:update")
    public R update(@RequestBody TPeopleDictionaryEntity tPeopleDictionary){
		tPeopleDictionaryService.updateById(tPeopleDictionary);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("user:tpeopledictionary:delete")
    public R delete(@RequestBody Integer[] ids){
		tPeopleDictionaryService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }


    /**
     * 查询字典下拉框(班组)
     */
   /* @RequestMapping("/listDictionary")
    public R listDictionary(){
        List<TPeopleDictionaryEntity> typeList = tPeopleDictionaryService.list(new QueryWrapper<TPeopleDictionaryEntity>()
                .eq("type", "10050")
        );
        return R.ok().put("typeList", typeList);
    }*/

    /**
     * 查询字典下拉框(衔级)
     */
    @RequestMapping("/listDictionaryTitle")
    public R listDictionaryTitle(){
        /*List<TPeopleDictionaryEntity> typeList = tPeopleDictionaryService.list(new QueryWrapper<TPeopleDictionaryEntity>()
                .eq("type", "10001")
        );*/
        List<TPeopleDictionaryEntity> typeList = tPeopleDictionaryService.listDictionaryTitle();
        return R.ok().put("typeList", typeList);
    }

    /*
    * 下拉框岗位
    * */
    @RequestMapping("/listDictionaryPost")
    public R listDictionaryPost(){
        /*List<TPeopleDictionaryEntity> typeList = tPeopleDictionaryService.list(new QueryWrapper<TPeopleDictionaryEntity>()
                .eq("type", "10010")
        );*/
        List<TPeopleDictionaryEntity> typeList = tPeopleDictionaryService.listDictionaryPost();
        return R.ok().put("typeList", typeList);
    }

    /*
    *  下拉框行政职务
    * */
    @RequestMapping("/listAdministration")
    public R listAdministration(){
        /*List<TPeopleDictionaryEntity> typeList = tPeopleDictionaryService.list(new QueryWrapper<TPeopleDictionaryEntity>()
                .eq("type", "10020")
        );*/
        List<TPeopleDictionaryEntity> typeList=tPeopleDictionaryService.listAdministration();
        return R.ok().put("typeList", typeList);
    }

    /*
    * 下拉框职务等级
    * */
    @RequestMapping("/listPostClass")
    public R listPostClass(){
        /*List<TPeopleDictionaryEntity> typeList = tPeopleDictionaryService.list(new QueryWrapper<TPeopleDictionaryEntity>()
                .eq("type", "10040")
        );*/
        List<TPeopleDictionaryEntity> typeList=tPeopleDictionaryService.listPostClass();
        return R.ok().put("typeList", typeList);
    }

    /*
    *  技术等级
    * */
    /*@RequestMapping("/listPostClass")
    public R list(){
        List<TPeopleDictionaryEntity> typeList = tPeopleDictionaryService.list(new QueryWrapper<TPeopleDictionaryEntity>()
                .eq("type", "10040")
        );
        return R.ok().put("typeList", typeList);
    }*/

    /**
     * 查询字典下拉框(班组)
     */
    @RequestMapping("/listDictionary")
    public R listDictionary(){
        List<TPeopleDictionaryEntity> typeList = tPeopleDictionaryService.listDictionary();
        return R.ok().put("typeList", typeList);
    }


    /**
     * 字典类型下拉选择
     */
    @RequestMapping("/getPeopleSelect")
    public R getPeopleSelect(){
        List<TPeopleDictionaryEntity> peoplesel = tPeopleDictionaryService.getPeopleSelect();
        return R.ok().put("peoplesel", peoplesel);
    }
    /**
     * 字典类型下拉选择
     */
    @RequestMapping("/getTrainingSelect")
    public R getTrainingSelect(){
        List<TTrainingDictionaryEntity> trainingsel = tPeopleDictionaryService.getTrainingSelect();
        return R.ok().put("trainingsel", trainingsel);
    }
    /**
     * 字典类型下拉选择
     */
    @RequestMapping("/getFightSelect")
    public R getFightSelect(){
        List<TFightDictionaryEntity> fightsel = tPeopleDictionaryService.getFightSelect();
        return R.ok().put("fightsel", fightsel);
    }
    /**
     * 退出类型
     */
    @RequestMapping("/outType")
    public R outType(){
        List<TPeopleDictionaryEntity> outtype = tPeopleDictionaryService.outType();
        return R.ok().put("outtype", outtype);
    }

}
